from rest_framework import serializers

from books import models


class BooksReadOnlySerializer(serializers.ModelSerializer):
    """ 书本序列化器（只读） """

    class Meta:
        model = models.BooksModel
        # 设置外键级联深度
        depth = 2
        fields = '__all__'


class BooksSerializer(serializers.ModelSerializer):
    """ 书本序列化器（读写） """

    class Meta:
        model = models.BooksModel
        fields = '__all__'


class BookshelfSerializer(serializers.ModelSerializer):
    """ 书架序列化器 """

    class Meta:
        model = models.BookshelfModel
        fields = '__all__'


class PublisherSerializer(serializers.ModelSerializer):
    """ 出版社序列化器 """

    class Meta:
        model = models.PublisherModel
        fields = '__all__'
